package com.inspur.gs.sbssdl.sbssgl.yxts.yxts.front.sbsstsjlsub_frm.voactions;
import com.inspur.edp.bff.entity.defaultvalue.VoDefaultValue;
import com.inspur.edp.bff.spi.action.retrievedefault.BeforeRetrieveDefaultAction;
import com.inspur.edp.bff.api.manager.context.RetrieveDefaultContext;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;

public class addDataBeforeVOAction extends BeforeRetrieveDefaultAction {

	public addDataBeforeVOAction(RetrieveDefaultContext context) {
		super(context);
	}
	@Override
	public void execute() {
		String devId = (String) this.getContext().getVariableData().getValue("devId");
		if (devId != null && !devId.isEmpty()) {
			VoDefaultValue voDefaultValue = new VoDefaultValue();
			voDefaultValue.getDefaultValue().put("devId", devId);

			String nowStringFormatter = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd 00:00:00"));
			Date nowDate = Date.from(LocalDateTime.parse(nowStringFormatter, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).atZone(ZoneId.systemDefault()).toInstant());
			voDefaultValue.getDefaultValue().put("rq", nowDate);
			this.getRetrieveDefaultContext().setVoDefaultValue(voDefaultValue);
		}

	}
}
